package com.nageoffer.jobtrain.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nageoffer.jobtrain.admin.remote.UserManageActualRemoteService;
import com.nageoffer.jobtrain.admin.remote.req.UserBlockingReqDTO;
import com.nageoffer.jobtrain.admin.remote.req.UserLiftingReqDTO;
import com.nageoffer.jobtrain.admin.remote.req.UserPageReqDTO;
import com.nageoffer.jobtrain.admin.remote.resp.UserPageRespDTO;
import com.nageoffer.jobtrain.common.web.result.Result;
import com.nageoffer.jobtrain.common.web.result.Results;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户接口控制层
 * author：唐晨
 */
@RestController
@RequiredArgsConstructor
public class UserController {
    private final UserManageActualRemoteService userManageActualRemoteService;

    /**
     * 用户分页查询
     */
    @PostMapping("/api/job-train/admin/toc/user/page")
    public Result<Page<UserPageRespDTO>> pageUserList(@RequestBody UserPageReqDTO requestParam) {
        return userManageActualRemoteService.pageUserList(requestParam.getCurrent(),
                requestParam.getSize(),
                requestParam.getPhoneNumber(),
                requestParam.getNickName());
    }

    /**
     * 用户状态拉黑功能
     */
    @PostMapping("/api/job-train/admin/toc/user/blocking")
    public Result<Void> blockingUserStatus(@RequestBody UserBlockingReqDTO requestParam) {
        userManageActualRemoteService.blockingUserStatus(requestParam);
        return Results.success();
    }

    /**
     * 用户状态解禁功能
     */
    @PostMapping("/api/job-train/admin/toc/user/lifting")
    public Result<Void> liftingUserStatus(@RequestBody UserLiftingReqDTO requestParam) {
        userManageActualRemoteService.liftingUserStatus(requestParam);
        return Results.success();
    }
}